/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: Define some macro for function's income arguments check.
 * Author: wanqian <wanqian10@huaiwei.com>
 * Create: 2023-11-16
 */

#ifndef __ARGUMENT_CHECK
#define __ARGUMENT_CHECK

#define CHECK_NULL_AND_RETURN(parg) do {     \
	if ((parg) == NULL)		     \
		return;			     \
	} while (0)
#define CHECK_NULL_AND_RETURN_VAL(parg, val) do {	\
	if ((parg) == NULL)				\
		return (val);				\
	} while (0)
#define CHECK_NULL_AND_RETURN_ON_CONDITION(parg, cond) do {	\
	if (cond)							\
		CHECK_NULL_AND_RETURN(parg);	\
	} while (0)
#define CHECK_ZERO_AND_RETURN(iarg) do {	\
	if ((iarg) == 0) \
		return;				\
	} while (0)
#define CHECK_ZERO_AND_RETURN_VAL(iarg, val) do {	\
	if ((iarg) == 0)				\
		return (val);				\
	} while (0)

#endif
